const express=require("express");
const router=express.Router();
const logcom=require("../model/logcoment");


router.get("/published",(req,res)=>{
    logcom.create(req.query).then(result=>{
        if(result){
            res.send({
                code:1,
                message:"评论成功"
            })
        }else{
            res.send({
                code:0,
                message:"评论失败"
            })
        }
    })
})

router.get("/toobtain",(req,res)=>{
    logcom
        .find({log:req.query.id})
        .sort({date:-1})
        .populate("user")
        .then(result=>{
        res.send({
            result
        })
    })
})

module.exports=router;